<%--
  Created by IntelliJ IDEA.
  User: 23827
  Date: 2019/9/22
  Time: 22:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>centerEdit</title>


    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
    <link rel="stylesheet" href="../../css/user/centerEdit.css" type="text/css">
    <!-- 引入bootstrap框架的样式文件 -->
    <link rel="stylesheet" href="../../plugins/bootstrap/css/bootstrap.css" type="text/css">
</head>

<body>

<%@ include file="../common/nav2.jsp"%>

<div style="overflow: hidden;margin-top: 50px">
    <!-- 左边 -->
    <div id="left">
        <a href="${path}/edit/list" class="list-group-item active">
            实名认证
        </a>
        <a href="${path}/information/list"  class="list-group-item">信息完善</a>
        <a href="${path}/number/list" class="list-group-item">手机绑定</a>
        <a href="${path}/address/list" class="list-group-item">地址管理</a>
        <a href="${path}/password/list" class="list-group-item">密码管理</a>
    </div>
    <!-- 右边 -->
    <div class="right">
        <!-- 右边第一层 -->

        <div class="right-first" id="realName">

        </div>
        <!-- 右边第二层 -->
        <div>
            <p class="right-1">*</p>
            <p class="right-2">实名认证</p><br><br><br>
            <input type="text" class="righttext-1" placeholder="请您输入身份证号" id="idCard" value="${realName.idCard}">
        </div>
        <!-- 右边第三层 -->
        <div>
            <p class="right-1">*</p>
            <p class="right-2">姓名</p><br><br><br>
            <input type="text" class="righttext-1" placeholder="请您输入姓名" id="sname" value="${realName.sname}">
        </div>
        <div>
            <button type="button" class="btn btn-primary"
                    style="margin-left: 20px;margin-top: 30px;width: 200px;height: 35px" id="save">提交认证</button>
        </div>

        <div id="status" style="margin-left: 20px;margin-top: 20px">

        </div>
    </div>



    </div>
</div>

<%@ include file="../common/footer.jsp"%>
<script >
    var rootPath="http://localhost:8081/";

    $("#save").click(function(){

        var sname = document.getElementById("sname").value;
        var idCard=document.getElementById("idCard").value;

        console.log(idCard);
        console.log(sname);

        var allData = {
            idCard:idCard,
            sname:sname
        };
        $.ajax({
            type: "post",
            url: rootPath+"edit/list2",
            dataType: "json",
            data: JSON.stringify(allData),
            contentType: "application/json; charset=utf-8",
            success:function(result){
                console.log(result.data)
                if(result.data.respMessage == "身份证信息匹配"){
                    $.ajax({
                        url:rootPath+"edit/add",    //请求的url地址
                        dataType:"json",   //返回格式为json
                        async:true,//请求是否异步，默认为异步，这也是ajax重要特性
                        data:JSON.stringify(allData),   //参数值
                        contentType: "application/json;charset=UTF-8",
                        type:"Post",   //请求方式
                        success:function(req){

                            //请求成功时处理
                        },
                    });
                }
                str ="<span id='text'>"+result.data.respMessage+" </span>";
                $("#status").html(str);
            }
        });
    })

</script>
<script>
    var rootPath="http://localhost:8081/";
    $.ajax({
        type: "post",
        url: rootPath+"edit/list3",
        dataType: "json",
//        data: JSON.stringify(allData),
        contentType: "application/json; charset=utf-8",
        success:function(result){
            console.log(result.data)
            if(result.data == 1){

                result.data="已实名"
            }else{
                result.data="未实名"

            }
            str2 =" <h4 class='characters1'>实名认证</h4>"+
                "<button type='button' class='btn btn-primary' id='right-first-button'>"+result.data+"</button>";

            $("#realName").html(str2);
        }
    });
</script>



<!-- bootstrap中的js插件依赖于jquery框架,所以必须先引入jquery的js文件 -->
<!--引入bootstrap的js文件-->
<script src="../../plugins/bootstrap/js/bootstrap.js"></script>
</body>

</html>
